# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-rake-contrib
_commit=d23737377289b21ad51973297f7a298b604fac9d
pkgver=1.0.0.20210616
pkgrel=1
pkgdesc='Additional libraries for Rake'
arch=(any)
url='https://github.com/ruby/rake-contrib'
license=(MIT)
depends=(ruby-rake)
makedepends=(ruby-minitest)
options=(!emptydirs)
source=(https://github.com/ruby/rake-contrib/archive/$_commit/$pkgname-$_commit.tar.gz)
sha256sums=('5d4e2bbd9d26180917162e86654d1c35f29a6f5e174aa02674bb05c321c04c58')

build() {
  local _gemdir="$(gem env gemdir)"
  cd rake-contrib-$_commit
  gem build rake-contrib.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    rake-contrib-1.0.0.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd rake-contrib-$_commit
  GEM_HOME="tmp_install/$_gemdir" rake
}

package() {
  cd rake-contrib-$_commit
  cp -a tmp_install/* "$pkgdir"/
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname/
}
